Passed
Pull Request — master (#47)
by
unknown
05:23
created

carousel.js ➔ _objectSpread   B

Complexity

Conditions 6

Size

Total Lines 18
Code Lines 10

Duplication

Lines 18
Ratio 100 %

Importance

Changes 0
Metric Value
cc 6
eloc 10
c 0
b 0
f 0
dl 18
loc 18
rs 8.6666
1
/*!
2
  * Bootstrap carousel.js v4.6.0 (https://getbootstrap.com/)
3
  * Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
4
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
5
  */
6
(function (global, factory) {
7
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('jquery'), require('./util.js')) :
8
  typeof define === 'function' && define.amd ? define(['jquery', './util'], factory) :
0 ignored issues
show
Bug introduced by
The variable define seems to be never declared. If this is a global, consider adding a /** global: define */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
9
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Carousel = factory(global.jQuery, global.Util));
0 ignored issues
show
Bug introduced by
The variable globalThis seems to be never declared. If this is a global, consider adding a /** global: globalThis */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
Best Practice introduced by
If you intend to check if the variable self is declared in the current environment, consider using typeof self === "undefined" instead. This is safe if the variable is not actually declared.
Loading history...
Comprehensibility introduced by
Usage of the sequence operator is discouraged, since it may lead to obfuscated code.

The sequence or comma operator allows the inclusion of multiple expressions where only is permitted. The result of the sequence is the value of the last expression.

This operator is most often used in for statements.

Used in another places it can make code hard to read, especially when people do not realize it even exists as a seperate operator.

This check looks for usage of the sequence operator in locations where it is not necessary and could be replaced by a series of expressions or statements.

var a,b,c;

a = 1, b = 1,  c= 3;

could just as well be written as:

var a,b,c;

a = 1;
b = 1;
c = 3;

To learn more about the sequence operator, please refer to the MDN.

Loading history...
10
}(this, (function ($, Util) { 'use strict';
11
12
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
13
14
  var $__default = /*#__PURE__*/_interopDefaultLegacy($);
15
  var Util__default = /*#__PURE__*/_interopDefaultLegacy(Util);
16
17
  function _defineProperties(target, props) {
18
    for (var i = 0; i < props.length; i++) {
19
      var descriptor = props[i];
20
      descriptor.enumerable = descriptor.enumerable || false;
21
      descriptor.configurable = true;
22
      if ("value" in descriptor) descriptor.writable = true;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
23
      Object.defineProperty(target, descriptor.key, descriptor);
24
    }
25
  }
26
27
  function _createClass(Constructor, protoProps, staticProps) {
28
    if (protoProps) _defineProperties(Constructor.prototype, protoProps);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
29
    if (staticProps) _defineProperties(Constructor, staticProps);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
30
    return Constructor;
31
  }
32
33
  function _extends() {
34
    _extends = Object.assign || function (target) {
0 ignored issues
show
Comprehensibility introduced by
It seems like you are trying to overwrite a function name here. _extends is already defined in line 33 as a function. While this will work, it can be very confusing.
Loading history...
35
      for (var i = 1; i < arguments.length; i++) {
36
        var source = arguments[i];
37
38
        for (var key in source) {
0 ignored issues
show
Complexity introduced by
A for in loop automatically includes the property of any prototype object, consider checking the key using hasOwnProperty.

When iterating over the keys of an object, this includes not only the keys of the object, but also keys contained in the prototype of that object. It is generally a best practice to check for these keys specifically:

var someObject;
for (var key in someObject) {
    if ( ! someObject.hasOwnProperty(key)) {
        continue; // Skip keys from the prototype.
    }

    doSomethingWith(key);
}
Loading history...
39
          if (Object.prototype.hasOwnProperty.call(source, key)) {
40
            target[key] = source[key];
41
          }
42
        }
43
      }
44
45
      return target;
46
    };
47
48
    return _extends.apply(this, arguments);
49
  }
50
51
  /**
52
   * ------------------------------------------------------------------------
53
   * Constants
54
   * ------------------------------------------------------------------------
55
   */
56
57
  var NAME = 'carousel';
58
  var VERSION = '4.6.0';
59
  var DATA_KEY = 'bs.carousel';
60
  var EVENT_KEY = "." + DATA_KEY;
61
  var DATA_API_KEY = '.data-api';
62
  var JQUERY_NO_CONFLICT = $__default['default'].fn[NAME];
63
  var ARROW_LEFT_KEYCODE = 37; // KeyboardEvent.which value for left arrow key
64
65
  var ARROW_RIGHT_KEYCODE = 39; // KeyboardEvent.which value for right arrow key
66
67
  var TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch
68
69
  var SWIPE_THRESHOLD = 40;
70
  var Default = {
71
    interval: 5000,
72
    keyboard: true,
73
    slide: false,
74
    pause: 'hover',
75
    wrap: true,
76
    touch: true
77
  };
78
  var DefaultType = {
79
    interval: '(number|boolean)',
80
    keyboard: 'boolean',
81
    slide: '(boolean|string)',
82
    pause: '(string|boolean)',
83
    wrap: 'boolean',
84
    touch: 'boolean'
85
  };
86
  var DIRECTION_NEXT = 'next';
87
  var DIRECTION_PREV = 'prev';
88
  var DIRECTION_LEFT = 'left';
89
  var DIRECTION_RIGHT = 'right';
90
  var EVENT_SLIDE = "slide" + EVENT_KEY;
91
  var EVENT_SLID = "slid" + EVENT_KEY;
92
  var EVENT_KEYDOWN = "keydown" + EVENT_KEY;
93
  var EVENT_MOUSEENTER = "mouseenter" + EVENT_KEY;
94
  var EVENT_MOUSELEAVE = "mouseleave" + EVENT_KEY;
95
  var EVENT_TOUCHSTART = "touchstart" + EVENT_KEY;
96
  var EVENT_TOUCHMOVE = "touchmove" + EVENT_KEY;
97
  var EVENT_TOUCHEND = "touchend" + EVENT_KEY;
98
  var EVENT_POINTERDOWN = "pointerdown" + EVENT_KEY;
99
  var EVENT_POINTERUP = "pointerup" + EVENT_KEY;
100
  var EVENT_DRAG_START = "dragstart" + EVENT_KEY;
101
  var EVENT_LOAD_DATA_API = "load" + EVENT_KEY + DATA_API_KEY;
102
  var EVENT_CLICK_DATA_API = "click" + EVENT_KEY + DATA_API_KEY;
103
  var CLASS_NAME_CAROUSEL = 'carousel';
104
  var CLASS_NAME_ACTIVE = 'active';
105
  var CLASS_NAME_SLIDE = 'slide';
106
  var CLASS_NAME_RIGHT = 'carousel-item-right';
107
  var CLASS_NAME_LEFT = 'carousel-item-left';
108
  var CLASS_NAME_NEXT = 'carousel-item-next';
109
  var CLASS_NAME_PREV = 'carousel-item-prev';
110
  var CLASS_NAME_POINTER_EVENT = 'pointer-event';
111
  var SELECTOR_ACTIVE = '.active';
112
  var SELECTOR_ACTIVE_ITEM = '.active.carousel-item';
113
  var SELECTOR_ITEM = '.carousel-item';
114
  var SELECTOR_ITEM_IMG = '.carousel-item img';
115
  var SELECTOR_NEXT_PREV = '.carousel-item-next, .carousel-item-prev';
116
  var SELECTOR_INDICATORS = '.carousel-indicators';
117
  var SELECTOR_DATA_SLIDE = '[data-slide], [data-slide-to]';
118
  var SELECTOR_DATA_RIDE = '[data-ride="carousel"]';
119
  var PointerType = {
120
    TOUCH: 'touch',
121
    PEN: 'pen'
122
  };
123
  /**
124
   * ------------------------------------------------------------------------
125
   * Class Definition
126
   * ------------------------------------------------------------------------
127
   */
128
129
  var Carousel = /*#__PURE__*/function () {
130
    function Carousel(element, config) {
131
      this._items = null;
132
      this._interval = null;
133
      this._activeElement = null;
134
      this._isPaused = false;
135
      this._isSliding = false;
136
      this.touchTimeout = null;
137
      this.touchStartX = 0;
138
      this.touchDeltaX = 0;
139
      this._config = this._getConfig(config);
140
      this._element = element;
141
      this._indicatorsElement = this._element.querySelector(SELECTOR_INDICATORS);
142
      this._touchSupported = 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0;
0 ignored issues
show
Bug introduced by
The variable navigator seems to be never declared. If this is a global, consider adding a /** global: navigator */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
143
      this._pointerEvent = Boolean(window.PointerEvent || window.MSPointerEvent);
144
145
      this._addEventListeners();
146
    } // Getters
147
148
149
    var _proto = Carousel.prototype;
150
151
    // Public
152
    _proto.next = function next() {
153
      if (!this._isSliding) {
154
        this._slide(DIRECTION_NEXT);
155
      }
156
    };
157
158
    _proto.nextWhenVisible = function nextWhenVisible() {
159
      var $element = $__default['default'](this._element); // Don't call next when the page isn't visible
160
      // or the carousel or its parent isn't visible
161
162
      if (!document.hidden && $element.is(':visible') && $element.css('visibility') !== 'hidden') {
163
        this.next();
164
      }
165
    };
166
167
    _proto.prev = function prev() {
168
      if (!this._isSliding) {
169
        this._slide(DIRECTION_PREV);
170
      }
171
    };
172
173
    _proto.pause = function pause(event) {
174
      if (!event) {
175
        this._isPaused = true;
176
      }
177
178
      if (this._element.querySelector(SELECTOR_NEXT_PREV)) {
179
        Util__default['default'].triggerTransitionEnd(this._element);
180
        this.cycle(true);
181
      }
182
183
      clearInterval(this._interval);
184
      this._interval = null;
185
    };
186
187
    _proto.cycle = function cycle(event) {
188
      if (!event) {
189
        this._isPaused = false;
190
      }
191
192
      if (this._interval) {
193
        clearInterval(this._interval);
194
        this._interval = null;
195
      }
196
197
      if (this._config.interval && !this._isPaused) {
198
        this._updateInterval();
199
200
        this._interval = setInterval((document.visibilityState ? this.nextWhenVisible : this.next).bind(this), this._config.interval);
201
      }
202
    };
203
204
    _proto.to = function to(index) {
205
      var _this = this;
206
207
      this._activeElement = this._element.querySelector(SELECTOR_ACTIVE_ITEM);
208
209
      var activeIndex = this._getItemIndex(this._activeElement);
210
211
      if (index > this._items.length - 1 || index < 0) {
212
        return;
213
      }
214
215
      if (this._isSliding) {
216
        $__default['default'](this._element).one(EVENT_SLID, function () {
217
          return _this.to(index);
218
        });
219
        return;
220
      }
221
222
      if (activeIndex === index) {
223
        this.pause();
224
        this.cycle();
225
        return;
226
      }
227
228
      var direction = index > activeIndex ? DIRECTION_NEXT : DIRECTION_PREV;
229
230
      this._slide(direction, this._items[index]);
231
    };
232
233
    _proto.dispose = function dispose() {
234
      $__default['default'](this._element).off(EVENT_KEY);
235
      $__default['default'].removeData(this._element, DATA_KEY);
236
      this._items = null;
237
      this._config = null;
238
      this._element = null;
239
      this._interval = null;
240
      this._isPaused = null;
241
      this._isSliding = null;
242
      this._activeElement = null;
243
      this._indicatorsElement = null;
244
    } // Private
245
    ;
246
247
    _proto._getConfig = function _getConfig(config) {
248
      config = _extends({}, Default, config);
249
      Util__default['default'].typeCheckConfig(NAME, config, DefaultType);
250
      return config;
251
    };
252
253
    _proto._handleSwipe = function _handleSwipe() {
254
      var absDeltax = Math.abs(this.touchDeltaX);
255
256
      if (absDeltax <= SWIPE_THRESHOLD) {
257
        return;
258
      }
259
260
      var direction = absDeltax / this.touchDeltaX;
261
      this.touchDeltaX = 0; // swipe left
262
263
      if (direction > 0) {
264
        this.prev();
265
      } // swipe right
266
267
268
      if (direction < 0) {
269
        this.next();
270
      }
271
    };
272
273
    _proto._addEventListeners = function _addEventListeners() {
274
      var _this2 = this;
275
276
      if (this._config.keyboard) {
277
        $__default['default'](this._element).on(EVENT_KEYDOWN, function (event) {
278
          return _this2._keydown(event);
279
        });
280
      }
281
282
      if (this._config.pause === 'hover') {
283
        $__default['default'](this._element).on(EVENT_MOUSEENTER, function (event) {
284
          return _this2.pause(event);
285
        }).on(EVENT_MOUSELEAVE, function (event) {
286
          return _this2.cycle(event);
287
        });
288
      }
289
290
      if (this._config.touch) {
291
        this._addTouchEventListeners();
292
      }
293
    };
294
295
    _proto._addTouchEventListeners = function _addTouchEventListeners() {
296
      var _this3 = this;
297
298
      if (!this._touchSupported) {
299
        return;
300
      }
301
302
      var start = function start(event) {
303
        if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) {
304
          _this3.touchStartX = event.originalEvent.clientX;
305
        } else if (!_this3._pointerEvent) {
306
          _this3.touchStartX = event.originalEvent.touches[0].clientX;
307
        }
308
      };
309
310
      var move = function move(event) {
311
        // ensure swiping with one touch and not pinching
312
        if (event.originalEvent.touches && event.originalEvent.touches.length > 1) {
313
          _this3.touchDeltaX = 0;
314
        } else {
315
          _this3.touchDeltaX = event.originalEvent.touches[0].clientX - _this3.touchStartX;
316
        }
317
      };
318
319
      var end = function end(event) {
320
        if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) {
321
          _this3.touchDeltaX = event.originalEvent.clientX - _this3.touchStartX;
322
        }
323
324
        _this3._handleSwipe();
325
326
        if (_this3._config.pause === 'hover') {
327
          // If it's a touch-enabled device, mouseenter/leave are fired as
328
          // part of the mouse compatibility events on first tap - the carousel
329
          // would stop cycling until user tapped out of it;
330
          // here, we listen for touchend, explicitly pause the carousel
331
          // (as if it's the second time we tap on it, mouseenter compat event
332
          // is NOT fired) and after a timeout (to allow for mouse compatibility
333
          // events to fire) we explicitly restart cycling
334
          _this3.pause();
335
336
          if (_this3.touchTimeout) {
337
            clearTimeout(_this3.touchTimeout);
338
          }
339
340
          _this3.touchTimeout = setTimeout(function (event) {
341
            return _this3.cycle(event);
342
          }, TOUCHEVENT_COMPAT_WAIT + _this3._config.interval);
343
        }
344
      };
345
346
      $__default['default'](this._element.querySelectorAll(SELECTOR_ITEM_IMG)).on(EVENT_DRAG_START, function (e) {
347
        return e.preventDefault();
348
      });
349
350
      if (this._pointerEvent) {
351
        $__default['default'](this._element).on(EVENT_POINTERDOWN, function (event) {
352
          return start(event);
353
        });
354
        $__default['default'](this._element).on(EVENT_POINTERUP, function (event) {
355
          return end(event);
356
        });
357
358
        this._element.classList.add(CLASS_NAME_POINTER_EVENT);
359
      } else {
360
        $__default['default'](this._element).on(EVENT_TOUCHSTART, function (event) {
361
          return start(event);
362
        });
363
        $__default['default'](this._element).on(EVENT_TOUCHMOVE, function (event) {
364
          return move(event);
365
        });
366
        $__default['default'](this._element).on(EVENT_TOUCHEND, function (event) {
367
          return end(event);
368
        });
369
      }
370
    };
371
372
    _proto._keydown = function _keydown(event) {
373
      if (/input|textarea/i.test(event.target.tagName)) {
374
        return;
375
      }
376
377
      switch (event.which) {
378
        case ARROW_LEFT_KEYCODE:
379
          event.preventDefault();
380
          this.prev();
381
          break;
382
383
        case ARROW_RIGHT_KEYCODE:
384
          event.preventDefault();
385
          this.next();
386
          break;
387
      }
388
    };
389
390
    _proto._getItemIndex = function _getItemIndex(element) {
391
      this._items = element && element.parentNode ? [].slice.call(element.parentNode.querySelectorAll(SELECTOR_ITEM)) : [];
392
      return this._items.indexOf(element);
393
    };
394
395
    _proto._getItemByDirection = function _getItemByDirection(direction, activeElement) {
396
      var isNextDirection = direction === DIRECTION_NEXT;
397
      var isPrevDirection = direction === DIRECTION_PREV;
398
399
      var activeIndex = this._getItemIndex(activeElement);
400
401
      var lastItemIndex = this._items.length - 1;
402
      var isGoingToWrap = isPrevDirection && activeIndex === 0 || isNextDirection && activeIndex === lastItemIndex;
403
404
      if (isGoingToWrap && !this._config.wrap) {
405
        return activeElement;
406
      }
407
408
      var delta = direction === DIRECTION_PREV ? -1 : 1;
409
      var itemIndex = (activeIndex + delta) % this._items.length;
410
      return itemIndex === -1 ? this._items[this._items.length - 1] : this._items[itemIndex];
411
    };
412
413
    _proto._triggerSlideEvent = function _triggerSlideEvent(relatedTarget, eventDirectionName) {
414
      var targetIndex = this._getItemIndex(relatedTarget);
415
416
      var fromIndex = this._getItemIndex(this._element.querySelector(SELECTOR_ACTIVE_ITEM));
417
418
      var slideEvent = $__default['default'].Event(EVENT_SLIDE, {
419
        relatedTarget: relatedTarget,
420
        direction: eventDirectionName,
421
        from: fromIndex,
422
        to: targetIndex
423
      });
424
      $__default['default'](this._element).trigger(slideEvent);
425
      return slideEvent;
426
    };
427
428
    _proto._setActiveIndicatorElement = function _setActiveIndicatorElement(element) {
429
      if (this._indicatorsElement) {
430
        var indicators = [].slice.call(this._indicatorsElement.querySelectorAll(SELECTOR_ACTIVE));
431
        $__default['default'](indicators).removeClass(CLASS_NAME_ACTIVE);
432
433
        var nextIndicator = this._indicatorsElement.children[this._getItemIndex(element)];
434
435
        if (nextIndicator) {
436
          $__default['default'](nextIndicator).addClass(CLASS_NAME_ACTIVE);
437
        }
438
      }
439
    };
440
441
    _proto._updateInterval = function _updateInterval() {
442
      var element = this._activeElement || this._element.querySelector(SELECTOR_ACTIVE_ITEM);
443
444
      if (!element) {
445
        return;
446
      }
447
448
      var elementInterval = parseInt(element.getAttribute('data-interval'), 10);
449
450
      if (elementInterval) {
451
        this._config.defaultInterval = this._config.defaultInterval || this._config.interval;
452
        this._config.interval = elementInterval;
453
      } else {
454
        this._config.interval = this._config.defaultInterval || this._config.interval;
455
      }
456
    };
457
458
    _proto._slide = function _slide(direction, element) {
459
      var _this4 = this;
460
461
      var activeElement = this._element.querySelector(SELECTOR_ACTIVE_ITEM);
462
463
      var activeElementIndex = this._getItemIndex(activeElement);
464
465
      var nextElement = element || activeElement && this._getItemByDirection(direction, activeElement);
466
467
      var nextElementIndex = this._getItemIndex(nextElement);
468
469
      var isCycling = Boolean(this._interval);
470
      var directionalClassName;
471
      var orderClassName;
472
      var eventDirectionName;
473
474
      if (direction === DIRECTION_NEXT) {
475
        directionalClassName = CLASS_NAME_LEFT;
476
        orderClassName = CLASS_NAME_NEXT;
477
        eventDirectionName = DIRECTION_LEFT;
478
      } else {
479
        directionalClassName = CLASS_NAME_RIGHT;
480
        orderClassName = CLASS_NAME_PREV;
481
        eventDirectionName = DIRECTION_RIGHT;
482
      }
483
484
      if (nextElement && $__default['default'](nextElement).hasClass(CLASS_NAME_ACTIVE)) {
485
        this._isSliding = false;
486
        return;
487
      }
488
489
      var slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName);
490
491
      if (slideEvent.isDefaultPrevented()) {
492
        return;
493
      }
494
495
      if (!activeElement || !nextElement) {
496
        // Some weirdness is happening, so we bail
497
        return;
498
      }
499
500
      this._isSliding = true;
501
502
      if (isCycling) {
503
        this.pause();
504
      }
505
506
      this._setActiveIndicatorElement(nextElement);
507
508
      this._activeElement = nextElement;
509
      var slidEvent = $__default['default'].Event(EVENT_SLID, {
510
        relatedTarget: nextElement,
511
        direction: eventDirectionName,
512
        from: activeElementIndex,
513
        to: nextElementIndex
514
      });
515
516
      if ($__default['default'](this._element).hasClass(CLASS_NAME_SLIDE)) {
517
        $__default['default'](nextElement).addClass(orderClassName);
518
        Util__default['default'].reflow(nextElement);
519
        $__default['default'](activeElement).addClass(directionalClassName);
520
        $__default['default'](nextElement).addClass(directionalClassName);
521
        var transitionDuration = Util__default['default'].getTransitionDurationFromElement(activeElement);
522
        $__default['default'](activeElement).one(Util__default['default'].TRANSITION_END, function () {
523
          $__default['default'](nextElement).removeClass(directionalClassName + " " + orderClassName).addClass(CLASS_NAME_ACTIVE);
524
          $__default['default'](activeElement).removeClass(CLASS_NAME_ACTIVE + " " + orderClassName + " " + directionalClassName);
525
          _this4._isSliding = false;
526
          setTimeout(function () {
527
            return $__default['default'](_this4._element).trigger(slidEvent);
528
          }, 0);
529
        }).emulateTransitionEnd(transitionDuration);
530
      } else {
531
        $__default['default'](activeElement).removeClass(CLASS_NAME_ACTIVE);
532
        $__default['default'](nextElement).addClass(CLASS_NAME_ACTIVE);
533
        this._isSliding = false;
534
        $__default['default'](this._element).trigger(slidEvent);
535
      }
536
537
      if (isCycling) {
538
        this.cycle();
539
      }
540
    } // Static
541
    ;
542
543
    Carousel._jQueryInterface = function _jQueryInterface(config) {
544
      return this.each(function () {
545
        var data = $__default['default'](this).data(DATA_KEY);
546
547
        var _config = _extends({}, Default, $__default['default'](this).data());
548
549
        if (typeof config === 'object') {
550
          _config = _extends({}, _config, config);
551
        }
552
553
        var action = typeof config === 'string' ? config : _config.slide;
554
555
        if (!data) {
556
          data = new Carousel(this, _config);
557
          $__default['default'](this).data(DATA_KEY, data);
558
        }
559
560
        if (typeof config === 'number') {
561
          data.to(config);
562
        } else if (typeof action === 'string') {
563
          if (typeof data[action] === 'undefined') {
564
            throw new TypeError("No method named \"" + action + "\"");
565
          }
566
567
          data[action]();
568
        } else if (_config.interval && _config.ride) {
569
          data.pause();
570
          data.cycle();
571
        }
572
      });
573
    };
574
575
    Carousel._dataApiClickHandler = function _dataApiClickHandler(event) {
576
      var selector = Util__default['default'].getSelectorFromElement(this);
577
578
      if (!selector) {
579
        return;
580
      }
581
582
      var target = $__default['default'](selector)[0];
583
584
      if (!target || !$__default['default'](target).hasClass(CLASS_NAME_CAROUSEL)) {
585
        return;
586
      }
587
588
      var config = _extends({}, $__default['default'](target).data(), $__default['default'](this).data());
589
590
      var slideIndex = this.getAttribute('data-slide-to');
591
592
      if (slideIndex) {
593
        config.interval = false;
594
      }
595
596
      Carousel._jQueryInterface.call($__default['default'](target), config);
597
598
      if (slideIndex) {
599
        $__default['default'](target).data(DATA_KEY).to(slideIndex);
600
      }
601
602
      event.preventDefault();
603
    };
604
605
    _createClass(Carousel, null, [{
606
      key: "VERSION",
607
      get: function get() {
608
        return VERSION;
609
      }
610
    }, {
611
      key: "Default",
612
      get: function get() {
613
        return Default;
614
      }
615
    }]);
616
617
    return Carousel;
618
  }();
619
  /**
620
   * ------------------------------------------------------------------------
621
   * Data Api implementation
622
   * ------------------------------------------------------------------------
623
   */
624
625
626
  $__default['default'](document).on(EVENT_CLICK_DATA_API, SELECTOR_DATA_SLIDE, Carousel._dataApiClickHandler);
627
  $__default['default'](window).on(EVENT_LOAD_DATA_API, function () {
628
    var carousels = [].slice.call(document.querySelectorAll(SELECTOR_DATA_RIDE));
629
630
    for (var i = 0, len = carousels.length; i < len; i++) {
631
      var $carousel = $__default['default'](carousels[i]);
632
633
      Carousel._jQueryInterface.call($carousel, $carousel.data());
634
    }
635
  });
636
  /**
637
   * ------------------------------------------------------------------------
638
   * jQuery
639
   * ------------------------------------------------------------------------
640
   */
641
642
  $__default['default'].fn[NAME] = Carousel._jQueryInterface;
643
  $__default['default'].fn[NAME].Constructor = Carousel;
644
645
  $__default['default'].fn[NAME].noConflict = function () {
646
    $__default['default'].fn[NAME] = JQUERY_NO_CONFLICT;
647
    return Carousel._jQueryInterface;
648
  };
649
650
  return Carousel;
651
652
})));
653
//# sourceMappingURL=carousel.js.map
654